package org.csu.jpetstorespringversion.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.jpetstorespringversion.mapper.ProductMapper;
import org.csu.jpetstorespringversion.mapper.UserMapper;
import org.csu.jpetstorespringversion.model.Product;
import org.csu.jpetstorespringversion.model.User;
import org.csu.jpetstorespringversion.service.ProductService;
import org.csu.jpetstorespringversion.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Autowired
    ProductMapper productMapper;
    public List<Product> getProductListByCategory(String categoryId){
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("category",categoryId);
        List<Product> products=productMapper.selectList(queryWrapper);
        return products;
    }

    public Product getProduct(String productId){
        QueryWrapper<Product>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("productid",productId);
        Product product=productMapper.selectOne(queryWrapper);
        return product;
    }

    public List<Product> searchProductList(String keywords){
        return null;
    }

}
